package org.september.pisces.imagesearch.controller;

import java.util.List;

import org.september.pisces.imagesearch.service.ImageFeatureService;
import org.september.pisces.imagesearch.vo.ImageSearchResult;
import org.september.simpleweb.auth.PublicMethod;
import org.september.simpleweb.controller.BaseController;
import org.september.simpleweb.model.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 */
@PublicMethod
@Controller
public class ImageSearchController extends BaseController {

	@Autowired
	private ImageFeatureService imageFeatureService;
	
    @ResponseBody
    @RequestMapping(value = Test)
    public ResponseVo<List<ImageSearchResult>> test() throws Exception {
    	String prefix = "D:\\work\\code\\github\\AIAS\\1_image_sdks";
    	
    	List<ImageSearchResult> result = imageFeatureService.search(prefix+"/test/zhaoliyin/1.png");
        return ResponseVo.<List<ImageSearchResult>>BUILDER().setData(result).setCode(ResponseVo.BUSINESS_CODE.SUCCESS);
    }
    
    @ResponseBody
    @RequestMapping(value = Add)
    public ResponseVo<String> add() throws Exception {
    	String prefix = "D:\\work\\code\\github\\AIAS\\1_image_sdks";
    	imageFeatureService.addImage(prefix+"/test/zhaoliyin/1.png");
    	imageFeatureService.addImage(prefix+"/test/zhaoliyin/2.png");
    	imageFeatureService.addImage(prefix+"/test/zhaoliyin/3.png");
    	imageFeatureService.addImage(prefix+"/test/zhaoliyin/4.png");
    	
    	imageFeatureService.addImage(prefix+"/test/huangshengyi/1.png");
    	imageFeatureService.addImage(prefix+"/test/huangshengyi/2.png");
    	imageFeatureService.addImage(prefix+"/test/huangshengyi/3.png");
    	imageFeatureService.addImage(prefix+"/test/huangshengyi/4.png");
    	
    	imageFeatureService.addImage(prefix+"/test/zhangyunlong/1.png");
    	imageFeatureService.addImage(prefix+"/test/zhangyunlong/2.png");
    	imageFeatureService.addImage(prefix+"/test/zhangyunlong/3.png");
    	imageFeatureService.addImage(prefix+"/test/zhangyunlong/4.png");
        return ResponseVo.<String>BUILDER().setData("").setCode(ResponseVo.BUSINESS_CODE.SUCCESS);
    }
    
    private static final String Mapping_Prefix = "/pisces/image/search";
	public static final String Test = Mapping_Prefix+"/test";
	public static final String Add = Mapping_Prefix+"/add";
	public static final String List_Data = Mapping_Prefix+"/listTmplData";
}
